package com.example.flowermall.config;

import com.example.flowermall.entity.Result;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(BadCredentialsException.class)
    public Result handleBadCredentialsException(BadCredentialsException ex) {
        // 密码错误时返回 HTTP 403 Forbidden 和 "密码错误" 信息
        return Result.error("密码错误", HttpStatus.FORBIDDEN);
    }

    // 其他全局异常处理可以在这里添加
}
